package com.examiner.controller;

import com.examiner.bean.test.NewTestUser;
import com.examiner.bean.vo.MyTestAndTestDBVo;
import com.examiner.page.QueryInfo;
import com.examiner.result.Result;
import com.examiner.service.CheckTestService;
import com.examiner.service.MyTestService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("checkTest")
@RestController
public class CheckTestController {

    @Resource
    private CheckTestService checkTestService;

    // 获取自评列表
    @PostMapping("/getCheckTestList/{id}")
    public Result<Object> getCheckTestList(@PathVariable("id") Integer id, @RequestBody QueryInfo queryInfo){
        List<MyTestAndTestDBVo> checkTestList;
        int total;
        Map<String, Object> data = new HashMap<>();
        try{
            checkTestList = checkTestService.getCheckTestList(id, queryInfo);
            total = checkTestService.getCheckTestListTotal(id,queryInfo);
        }catch (Exception e){
            e.printStackTrace();
            return Result.RESULT(201,"获取考评记录失败",false,null);
        }
        data.put("checkTestList",checkTestList);
        data.put("total",total);
        return Result.RESULT(200,"成功获取考评记录",true,data);
    }
}
